<!--suppress ALL-->
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改参试设备')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-examination-edit" th:object="${examination}">
            <input name="examinationId" th:field="*{examinationId}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">设备名称：</label>
                <div class="col-sm-8">
                    <input name="examinationName" th:field="*{examinationName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">部门：</label>
                <div class="col-sm-8">
                    <input name="deptName" onclick="selectDeptTree()" id="treeName" th:field="*{deptName}" required class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">存放位置：</label>
                <div class="col-sm-8">
                    <input name="storeroomName" th:field="*{storeroomName}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">设备型号：</label>
                <div class="col-sm-8">
                    <select name="examinationType" class="form-control m-b" required th:with="type=${@dict.getType('examination_type')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{examinationType}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">创建人：</label>
                <div class="col-sm-8">
                    <input name="founder" th:field="*{userName}" class="form-control" type="text" required readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">设备状态：</label>
                <div class="col-sm-8">
                    <select name="examinationStatus" readonly class="form-control m-b" required th:with="type=${@dict.getType('examination_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{examinationStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">使用状态：</label>
                <div class="col-sm-8">
                    <select name="useStatus" readonly class="form-control m-b" required th:with="type=${@dict.getType('examination_use_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{useStatus}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="note" class="form-control">[[*{note}]]</textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <input type="hidden" name="file" th:field="*{file}">
                    <div class="file-loading">
                        <input class="form-control file-upload" id="file" name="file" type="file">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js"/>
    <script th:inline="javascript">
        var prefix = ctx + "examination/examination";
        $("#form-examination-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-examination-edit').serialize());
            }
        }

        $(".file-upload").each(function (i) {
            var val = $("input[name='" + this.id + "']").val()
            $(this).fileinput({
                'uploadUrl': ctx + 'common/upload',
                initialPreviewAsData: true,
                initialPreview: [val],
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                $("input[name='" + event.currentTarget.id + "']").val(data.response.url)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
            $(this).fileinput('_initFileActions');
        });

        /* 用户管理-新增-选择部门树 */
        function selectDeptTree() {
            var treeId = $("#treeId").val();
            var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
            var url = ctx + "system/user/selectDeptTree/" + deptId;
            var options = {
                title: '选择部门',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero) {
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>